import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class Test14 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: [
          BuildItemWidget(
              BuildItem(Icons.ac_unit, Colors.blue, "消息中心", NoticeText("2"))),
          Divider(),
          BuildItemWidget(
              BuildItem(Icons.ac_unit, Colors.green, "我赞过得", Text("121赞"))),
          Divider(),
          BuildItemWidget(
              BuildItem(Icons.star, Colors.yellow, "收藏集", Text("2个"))),
          Divider(),
          BuildItemWidget(
              BuildItem(Icons.lock, Colors.yellow, "易购小测", Text("100个"))),
          Divider(),
          BuildItemWidget(
              BuildItem(Icons.money_off, Colors.blue, "我的钱包", Text("10万"))),
        ],
      ),
    );
  }
}

class BuildItem {
  IconData iconData;
  Color iconColor;
  String title;
  Widget end;

  BuildItem(this.iconData, this.iconColor, this.title, this.end);
}

class BuildItemWidget extends StatelessWidget {
  BuildItem buildItem;

  BuildItemWidget(this.buildItem);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 50,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          SizedBox(width: 15),
          Icon(
            buildItem.iconData,
            size: 30,
            color: buildItem.iconColor,
          ),
          SizedBox(width: 15),
          Expanded(
              child: Text(buildItem.title,
                  style: TextStyle(color: Colors.grey.withOpacity(.5)))),
          buildItem.end,
          SizedBox(width: 15)
        ],
      ),
    );
  }
}

class NoticeText extends StatelessWidget {
  String number;

  NoticeText(this.number);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(left: 15, top: 5, bottom: 5, right: 15),
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(20.0), color: Colors.red),
      child: Text(number, style: TextStyle(color: Colors.white, fontSize: 14)),
    );
  }
}
